package com.bwie.list.controller;

import com.bwie.common.domain.po.Food;
import com.bwie.common.domain.po.Order;
import com.bwie.common.result.Result;
import com.bwie.list.service.FoodService;
import com.bwie.list.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    /**
     * 订单表
     * @return
     */
    @PostMapping("/findOrderList")
    public Result<List<Order>> findFoodList(){
        List<Order> orders =  orderService.findOrderList();
        return Result.success(orders);
    }

    @PostMapping("/addOrder")
    public Result addOrder(@RequestBody Order order){
        orderService.addOrder(order);
        return Result.success(order);
    }

    /**
     * 退款
     * @param orderId
     * @return
     */
    @GetMapping("/delOrder")
    @Scheduled(cron = "* * 0/30 * * ?")
    public Result delOrder(@RequestParam Integer orderId){
        orderService.delOrder(orderId);
        return Result.success(orderId);
    }



}
